import request from './request';

export  const getCartTotalPrice=async ()=>{
  const { result }=await request({
    url:"/user/shoppingCart/list"
  })
  if (!result || !Array.isArray(result)) {
    return 0;
  }
  // 计算总价
  const totalPrice = result.reduce((total, item) => {
    console.log();
    const price = parseFloat(item.amount) || 0;
    const number = parseInt(item.number) || 0;
    return total + (price * number);
  }, 0);
  return totalPrice;
}